/*

NeatUpload - an HttpModule and User Controls for uploading large files
Copyright (C) 2005  Dean Brettle

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

using System;
using System.Collections;
using System.Collections.Specialized;

namespace Brettle.Web.NeatUpload
{
    [Serializable]
	public abstract class UploadStorageProvider
	{
		public abstract void Initialize(string name, NameValueCollection attrs);

		public abstract string Description { get; }

		public abstract string Name { get; }


		/* Subclasses must override one of the following 2 overloads. Subclasses written for NeatUpload 1.1 override
		the first overload.  Subclasses written for NeatUpload 1.2 override the second overload. */
		public virtual UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName,
		                                                string contentType)
		{
	      	return this.CreateUploadedFile(context, controlUniqueID, fileName, contentType, null);
		}                                               
		
		public virtual UploadedFile CreateUploadedFile(UploadContext context, string controlUniqueID, string fileName,
		                                                  string contentType, UploadStorageConfig storageConfig)
		{
	      	if (storageConfig != null && storageConfig.Count != 0)
	      	{
	      		throw new ApplicationException(this.Name + " doesn't understand InputFile.StorageConfig.");
	      	}
	      	return this.CreateUploadedFile(context, controlUniqueID, fileName, contentType);
		}
		
		public virtual UploadStorageConfig CreateUploadStorageConfig()
		{
			return new UploadStorageConfig();
		}
	}
}
